package tech.eyao.hs60x.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jiguang.common.utils.StringUtils;
import tech.eyao.hs60x.dao.AppVersionDao;
import tech.eyao.hs60x.dto.BaseResult;
import tech.eyao.hs60x.enums.ExceptionCodeEnum;
import tech.eyao.hs60x.model.domain.AppVersionDO;
import tech.eyao.hs60x.service.AppVersionService;

/**
 * 类AppVersionServiceImpl.java的实现描述：TODO 类实现描述
 * 
 * @author fengjianchao 2018年1月31日 下午5:26:18
 */
@Service
public class AppVersionServiceImpl implements AppVersionService {
    private static final Logger logger = LoggerFactory.getLogger(AppVersionServiceImpl.class);

    @Autowired
    private AppVersionDao       appVersionDao;

    @Override
    public boolean addAppVersion(AppVersionDO appVersionDO) {
        return appVersionDao.addAppVersion(appVersionDO);
    }

    @Override
    public BaseResult queryAppVersionByAppId(String appId) {
        logger.info(">>>>>>.queryAppVersionByAppId start:{}", appId);
        BaseResult baseResult = new BaseResult();
        try {
            List<AppVersionDO> appVersionList = new ArrayList<AppVersionDO>();
            // TODO Auto-generated method stub
            if (StringUtils.isEmpty(appId)) {
                return BaseResult.isFailure(ExceptionCodeEnum.ERROR_PARAMERROR.getCode(),
                        ExceptionCodeEnum.ERROR_PARAMERROR.getMessage());
            }
            appVersionList = appVersionDao.queryAppVersionByAppId(appId);
            baseResult.setData(appVersionList);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return baseResult;
    }

}
